<link rel="stylesheet" type="text/css" media="all" href="/static/assets/css/daterangepicker-bs3.css" />
<!--<script type="text/javascript" src="/static/assets/js/jquery-1.8.3.min.js"></script>-->
<!--<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>-->
<script type="text/javascript" src="/static/assets/js/moment.js"></script>
<script type="text/javascript" src="/static/assets/js/daterangepicker.js"></script>
<input hidden="hidden" id="navValue" value="分红权">
<div class="page-content">
    <div class="page-header">
        <h1>
            账户资产
            <small>
                <i class="ace-icon fa fa-angle-double-right"></i>
                所有分红权明细
            </small>
        </h1>
    </div><!-- /.page-header -->
    <div class="row">
        <from class="form-horizontal user-data" role="form">
            <div class="form-group">
                <div class="col-md-2 no-margin-right no-padding-right">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1"> 交易方式: </label>
                    <select class="type" name="type">
                        <option name="" value="0">选择方式</option>
                        <option name="" value="1" {if $type=='1'}selected = "selected"{else}{/if}>购物返还</option>
                        <option name="" value="2" {if $type=='2'}selected = "selected"{else}{/if}>下级购物返还</option>
                        <option name="" value="4" {if $type=='4'}selected = "selected"{else}{/if}>后台操作</option>
                    </select>
                </div>
                <div class="col-md-2 no-margin-right no-padding-right" >
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1"> 账&nbsp;号: </label>
                    <input type="text" name="phone" placeholder="请输入账号" class="col-sm-8" value="">
                </div>

                <div class="col-md-2">
                    <div class="input-prepend input-group">
                        <span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i></span>
                        <!-- <input class="date" id="startDate" type="date" name="startDate" value="{:input('get.startDate')}">- --->
                        <input class="date" id="endDate" type="date" name="endDate" value="{:input('get.endDate')}">
                    </div>
                </div>
                <button type="submit" id="searchBtn" style="margin-left: 30px;" class="dt-button buttons-collection buttons-colvis btn btn-white btn-primary btn-bold" tabindex="0" aria-controls="dynamic-table" data-original-title="" title="查询"><span><i class="fa fa-search bigger-110 blue"></i></span></button>
            </div>
            <input type="hidden" class="url" value="{:url('shareholders/shares')}"/>
        </from>
    </div><!-- /.row -->
    {if !empty($list)}
    <div class="row">
        <div class="col-xs-12">
            <table id="simple-table" class="table  table-bordered table-hover">
                <thead>
                <tr>
                    <th class="center">
                      序号
                    </th>
                    <th class="center">账号</th>
                    <th class="center">姓名</th>
                    <th class="center">交易方式</th>
                    <th class="center">数量</th>
                    <th class="center">剩余分红权</th>
                    <th class="center">发起账号</th>
                    <th class="center">收到账号</th>
                    <th class="center">交易时间</th>
                </tr>
                </thead>
                <tbody>
                {foreach $list as $key=> $val}
                <tr  class="center">
                    <td>
                  <?php echo ($page-1)*10+$key+1?>
                    </td>
                    <td><a href="{:url('shareholders/shares')}?phone={$val['phone']}" style="color: #000000">{$val['phone']}</a></td>
                    <td>{$val['realname']}</td>
                    <td>
                        {if condition="($val['type'] eq 1)"} 购物返还
                        {elseif condition="$val['type'] eq 2"/}下级购物返还
                        {elseif condition="$val['type'] eq 4"/} 后台操作
                        {else/} ??
                        {/if}
                    </td>
                    <td>{if $val['num']>0}<div style="color: red">+{$val['num']}</div>{else/}<div style="color: #008000">{$val['num']}</div>{/if}</td>
                    <td>{$val['after_change']}</td>
                    <td>

                        {if condition="($val['type'] eq 4)"}
                        admin
                        {else/}  {$val['giver']}
                        {/if}
                    </td>
                    <td>{$val['phone']}</td>
                    <td>{$val['update_time']}</td>
                </tr>
                {/foreach}
                </tbody>
            </table>
            {$page_html['html']}
        </div><!-- /.span -->
    </div><!-- /.row -->
    {else/}
    <div class="row" style="font-size: 14px;margin-top: 50px;"><center>{$message}</center></div>
    {/if}
</div>

<script>
    $(function () {
        $("#searchBtn").click(function () {
            var url= $(".url").val();
            var reg = /^1[3578]\d{9}$/;
            var phone = $('input[name="phone"]').val();
            var giver = $('input[name="giver"]').val();
            var type = $('.type').val();
            var id=$('.id').html();
            var endDate = $("#endDate").val();
            var text_href = '';
            if(phone!=""){
                if(reg.test(phone)){
                    text_href += "&phone="+phone;
                }
                else{
                    alert("请输入正确的手机号码");
                    $('input[name="phone"]').val('');
                    return false;

                }
            }
            if(reg.test(giver)){
                text_href += "&giver="+giver;
            }
            if(!text_href){
                text_href += "&endDate="+endDate;
            }else{
                text_href += "&endDate="+endDate;
            }
            if(text_href){
                text_href = "?"+text_href;
            }
            id="&id="+id;
            if(type){
                type_href="&type="+type;
            }
            if(type&&phone!=''){
                location.href=url.split('?')[0]+text_href+id+type_href;
            }
            else{
                type_href="?type="+type+"&endDate="+endDate;
                location.href=location.href.split('?')[0]+type_href;
            }
        });
        $(document).keyup(function(event){
            if(event.keyCode ==13){
                $("#searchBtn").trigger("click");

            }
        });
    })


</script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#search_date').daterangepicker({ singleDatePicker: true }, function(start, end, label) {
            console.log(start.toISOString(), end.toISOString(), label);
        });
    });
</script>